package com.zch.research.mqtt.provider.callback;

import com.alibaba.fastjson.JSON;
import com.zch.client.spring.mqtt.callback.MqttClientRootCallback;
import com.zch.client.spring.mqtt.dto.MqttConsumerMessage;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.IMqttAsyncClient;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;



@Slf4j
@Configuration
public class MqttProviderCallBack extends MqttClientRootCallback {


    @Override
    public void onClosed(Throwable throwable) {
        log.error("onClosed error:{}",throwable.getMessage());
    }

    @Override
    public void onMessage(MqttConsumerMessage consumerMessage) {
        log.info("onMessage:{}",JSON.toJSONString(consumerMessage));
    }

    @Override
    public void onDeliverServer(MqttMessage mqttMessage) {
        log.info("onDeliverServer:{}",JSON.toJSONString(mqttMessage));
    }
}
